package com.bizmerce.rnd.oms.codemng.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.bizmerce.rnd.oms.codemng.service.CodeMngService;
import com.bizmerce.rnd.oms.codemng.service.DeMinimisParamVO;
import com.bizmerce.rnd.oms.codemng.service.DeMinimisVO;
import com.bizmerce.rnd.oms.codemng.service.FtaSearchVO;
import com.bizmerce.rnd.oms.codemng.service.FtaVO;
import com.bizmerce.rnd.oms.codemng.service.HsCodeSearchVo;
import com.bizmerce.rnd.oms.codemng.service.HsCodeVO;
import com.bizmerce.rnd.oms.codemng.service.OffshoreVO;
import com.bizmerce.rnd.oms.codemng.service.ViewVO;

@Service("codeMngService")
public class CodeMngServiceImpl implements CodeMngService {

	@Resource(name = "ftaDAO")
	FtaDAO ftaDAO;

	@Resource(name = "offshoreDAO")
	OffshoreDAO offshoreDAO;

	@Resource(name = "deminimisDAO")
	DeMinimisDAO deminimisDAO;

	@Resource(name = "viewDAO")
	ViewDAO viewDAO;

	@Resource(name = "hscodeDAO")
	HsCodeDAO hscodeDAO;

	/**
	 * FTA협정관리
	 */
	public List<FtaVO> selectFtas(FtaSearchVO searchVO) {
		return ftaDAO.selectFtas(searchVO);
	}

	public int selectFtasCount() {
		return ftaDAO.selectFtasCount();
	}

	public void apply(FtaSearchVO searchVO) {
		for (String ftaId : searchVO.getIds()) {
			ftaDAO.apply(ftaId);
		}
	}

	public void noApply(FtaSearchVO searchVO) {
		for (String ftaId : searchVO.getIds()) {
			ftaDAO.noApply(ftaId);
		}
	}

	/**
	 * FTA협정관리 - 협정내역
	 */
	public FtaVO selectFta(String ftaId) {
		return ftaDAO.selectFta(ftaId);
	}

	public void updateFta(FtaVO fta) {
		ftaDAO.updateFta(fta);
	}

	/**
	 * 역외가공기준
	 * 
	 * 검색 조건 : 세번부호
	 */
	public List<OffshoreVO> selectOffById(FtaSearchVO searchVO) {
		return offshoreDAO.selectOffById(searchVO);
	}
	
	public int selectOffCount(FtaSearchVO searchVO) {
		return offshoreDAO.selectOffCount(searchVO);
	}

	/**
	 * 누적기준 적용여부
	 */
	public FtaVO selectCum(String id) {
		return ftaDAO.selectCum(id);
	}

	public void updateCum(String id, boolean apply) {
		ftaDAO.updateCum(id, apply);
	}

	/**
	 * 미소기준
	 */
	public List<DeMinimisVO> selectDeMin(String id) {
		return deminimisDAO.selectDeMin(id);
	}

	public void updateDeMin(String id, DeMinimisParamVO dem) {
		deminimisDAO.updateDemin(id, dem);
	}
	
	/**
	 * /** 품목별기준
	 */
	public List<ViewVO> selectView(FtaSearchVO searchVO) {
		return viewDAO.selectView(searchVO);
	}
	
	public int selectViewCount(FtaSearchVO searchVO) {
		return viewDAO.selectViewCount(searchVO);
	}

	/**
	 * HSCode 관리
	 */
	public List<HsCodeVO> selectHsCds(FtaSearchVO searchVO){
		return hscodeDAO.selectHsCds(searchVO);
	}

	public int selectHsCdCount(FtaSearchVO searchVO){
		return hscodeDAO.selectHsCdCount(searchVO);
	}
}